I2C PROTOCOL ANALYSER

Overview

The I2C Protocol Analyzer allows you to monitor and interact with the I2C bus. The analyzer has two purposes: to allow you to view data sent along the I2C-bus and to permit you to send data onto the I2C-bus either as a master or as a slave device. This makes it invaluable both as a debugging instrument but also as a development and testing aid when writing your own I2C routines (not to mention being a fraction of the cost of it’s hardware equivalent).

The Schematic Part

The schematic part for the I2C Protocol Analyzer is extremely simple as shown below.

Pin Descriptions

SCL Pin:

The SCL pin is a bi-directional pin which is connected to the clock line of your I2C-bus

SDA Pin:

The SDA pin is a bi-directional data line for the I2C-bus.

TRIG Pin:

The TRIG pin is an input that causes the successive stored sequences to be placed onto the output queue.

The I2C Debugger Window

When a simulation is paused or free running the Protocol Analyzer window will become available (if it does not automatically appear it can be launched from the Debug Menu in ISIS). This screen is split into several areas and allows you not only to monitor the activity on the I2C bus but also to stimulate the bus either as a Master or Slave device.

 

Note that free running a simulation with lots of I2C bus activity and a protocol  analyzer will incur a significant performance hit. While certainly not a problem when debugging or monitoring activity it can be useful to detach the device for non-bus related simulation passes.

 Input Data Display

The main window area (the top left portion of the popup) shows you all the activity recorded on the bus. As can be seen from the example above you can drill down to the level of viewing individual bit transmissions. The special sequence characters used to denote activity should be fairly obvious but is covered in more detail here.

When viewing at byte level or higher the time of the start and the stop of the sequence  is recorded. When viewing at bit level both the logic state of the pins and the bit designator is recorded in the display alongside the time.

While not visible on the screenshot above the arrows are bi-directional to indicate transmission or reception of data (reception in the case above) and the arrow itself will appear with a question mark if an invalid sequence is detected. This, together with the ability to drill down into individual bit data is invaluable when debugging potential problems.

 Predefined Sequences List

The predefined sequences list at the top right displays a queue of pre-programmed data sequences that can be transmitted via the SDA pin under the control of the SCL pin. You can add a pre-defined sequence by typing in the Sequence Entry Box as described below (use the Add button to commit the sequence to this list).

Double clicking on a predefined sequence  (or highlighting the predefined sequence and clicking on the Queue control button) while the simulation is running will add that sequence to the Buffered/Queued Sequence list for transmission on the bus. Note that the time for transmission depends on bus activity, whether we are a master or slave device etc. and so may well not be instantaneous.

Buffered Sequences List

The buffered sequences list is gated on the 'Hide Queued Sequences' checkbox and opens to the right of the Input Data Display when activated. It displays a queue of sequences that will be transmitted by the I2C terminal at the next available opportunity. You can add a buffered sequence by typing in the Sequence Entry Box as described below (Use the Queue button to commit the sequence to this list).

 Sequence Entry Box

This box (near the bottom right of the window) allows you to enter sequences to either places on the programmed sequence list or to immediately place on the output queue to be sent to the SDA pin at the next available opportunity. The following syntax is supported.

Syntax Description

'0x'

Can be used as a prefix to denote hexadecimal values (e.g 0xFE)

'$'

Can be used as a prefix to denote hexadecimal values (e.g %FE)

'h'

Can be used as a prefix to denote hexadecimal values (e.g FEh)

'%'

Can be used as a prefix to denote binary values (e.g %1101)

'b'

Can be used as a prefix to denote binary values (e.g 1101b)

'd'

Can be used as a prefix to denote decimal values (e.g 47d)

Note that hexadecimal and binary values must have either a prefix or suffix qualifier. The decimal suffix is optional. Strings must be enclosed in either double or single quotation marks.

Use the Control Buttons to determine whether a given sequence is added to the Pre-definedSequence List or to the Buffered/Queued Sequence List.

Control Buttons

The control buttons are used to allow you to provide stimulus to the I2C bus. The protocol analyzer is fully capable of acting as either a master or as a slave device so this provides an invaluable way of testing your I2C implementation.

Add Button

Use this to commit a sequence defined in the Sequence Entry Box to the Pre-defined sequences list for later use.

Delete Button

Use this to delete a sequence in the Pre-defined sequences list.

Queue Button

Use this button to queue selected items either directly from the Sequence Entry Box or from the Pre-defined  Sequence List. Queued items will then appear in the Buffered/Queued Sequences List.

Arm Input Display

When selected data will stream to the input display. Since there can be a great deal of traffic this checkbox is intended to be used as a filter. Notably, during a debugging session, one might disarm the display until a relevant breakpoint is hit before arming the display and single stepping through the communication code. Leaving the checkbox selected all of the time will impact simulation performance.

Hide Queued Sequences

When selected the queued sequences window will be hidden. This is the default since the most common configuration is a simple bus monitor where it is not relevant.

Model Properties

The I2C Debugger has a number of properties which allow you to configure it as required. All properties are accessible via the Edit Component dialogue form (right click on the schematic part to highlight and then left click to edit). Details of individual properties are given below :

Property Description

ADDRESS1

If you are using the terminal to simulate a slave device, this property specifies the first address byte of the slave device address. the least significant bit is used by the master to indicate if the transmission is a read or write and is ignored for the purposes of addressing. If you leave this property at its default or blank then terminal will not act as a slave device.

ADDRESS2

If you are using the terminal to simulate a slave device and you wish to use 10 bit addressing, this property allows you to specify the second address byte. If you leave this blank then 7 bit addressing is assumed.

STOPONEMPTY

Indicates if the simulation should be paused when the output buffer is empty and a byte is required to be sent.

CLOCKFREQ

When in master mode this controls the clock frequency on SCL.

SEQUENCE_FILE

Allows you to specify the file name of the text file where predefined output sequences are stored. If this property is left blank sequences are stored as part of the devices properties.

AUTOLOAD

Controls if the predefined sequences are immediately placed into the sequence queue upon simulation start-up.

TIMEPREC

Allows you to specify the number of decimal places by which time is to be displayed.

WRAPLENGTH

Specifies the number of items permitted on a single line before a new line is created.

Using the I2C Debugger

To receive data with the I2C Debugger:

Viewing data on the I2C-bus requires that you connect the SCL and SDA pins of the terminal to the relevant pins in your design. Data on the I2C-bus will be displayed in the upper left hand side of the protocol analyzer window as hexadecimal values and special sequence characters.

To transmit data with the I2C Debugger:

Sending data over the I2C-bus requires that you connect the SCL and SDA pins of the protocol analyzer to the relevant pins in your design.

Transmission data entry is done in the lower right hand side of the terminal window, just above the buttons. Entries can be single words, comma or space separated sequences of words, or text strings enclosed in double or single quotation marks. A word can be numerical values or special control signals.

Once you have entered your transmission sequence you may either directly queue the data sequence to be sent or have the data sequence placed on the predefined sequences list for later use. To immediately place the transmission sequence onto the buffered sequences list press the queue button, to place the transmission sequence into the predefine sequences list press the add button.

To place a copy of one of the predefined sequences into the buffered sequences queue, ensure the sequence entry box is empty, select the predefined sequence then press the queue button.

To remove an entry from the predefined sequences, select the predefined sequence to be removed, then press the delete button.

You can dock the I2C window by dragging it to the border of the editing area. This has the advantage of clearing the editing window from obstructions but may limit vertical data. You can undock via the icon at the top right (when docked) and close / open from the command on the Debug menu.

Syntax Reference

The following details the syntax used by the protocol analyzer to indicate conditions on the I2C bus.

Syntax Description

S

Used to denote a start condition.

Sr

Used to denote a restart condition.

P

Used to denote a stop condition.

N

Used to denote a negative acknowledge condition.

A

Used to denote an acknowledge condition.

L

Used to signify that arbitration has been lost, switching to master mode.

*

Used to denote partial data received.

?

Used to denote invalid logic levels detected.